<% content_for :content do %>

  <!-- widget grid -->
  <section id="widget-grid" class="">
  
    <div class="row">
      <div class="col-sm-12">
        <div class="well">
          <%= simple_form_for :wifi_log, url: admin_wifi_logs_path, :defaults => { :input_html => { :class => "form-control" } }, method: 'get', html: { class: "form-inline" } do |f| %> 
            <div class="form-group string">
              <%= f.input_field :branch, class: "form-control", selected: params[:wifi_log][:branch], collection: [['联通', 'liantong']], prompt: '运营商' %>
            </div>
            <div class="form-group string">
              <%= f.text_field :username, class: "form-control", value: params[:wifi_log][:username], placeholder: "账号" %>
            </div>            
            <div class="form-group string">
              <%= f.text_field :mobile_number, class: "form-control", value: params[:wifi_log][:mobile_number], placeholder: "用户手机号" %>
            </div>            
            <div class="form-group string">
              <%= f.input_field :used, class: "form-control", selected: params[:wifi_log][:used], collection: [['使用中', true], ['使用完毕', false]], prompt: '状态' %>
            </div>
            <div class="form-group string">
              <%= f.text_field :mac, class: "form-control", value: params[:wifi_log][:mac], placeholder: "MAC" %>
            </div>
            <div class="form-group string">
              <%= f.text_field :imei, class: "form-control", value: params[:wifi_log][:imei], placeholder: "IMEI" %>
            </div>
            <div class="form-group string">
              <%= f.text_field :start_at, class: "form-control datepicker", "data-dateformat" => "yy-mm-dd", value: params[:wifi_log][:start_at], placeholder: "开始时间" %>
            </div>
            <div class="form-group string">
              <%= f.text_field :end_at, class: "form-control datepicker", "data-dateformat" => "yy-mm-dd", value: params[:wifi_log][:end_at], placeholder: "结束时间" %>
            </div>
            <%= f.submit "搜 索", :class => "btn btn-default"%>
            <%= f.submit "导 出", :class => "btn btn-default"%>
          <% end %>
        </div> <!-- end well div -->
      </div>
    </div>

    <!-- row -->
    <div class="row">
  
      <!-- NEW WIDGET START -->
      <article class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
        
        <!-- Widget ID (each widget will need unique ID)-->
        <div class="jarviswidget jarviswidget-color-blueDark" id="wid-id-3" data-widget-editbutton="false" data-widget-colorbutton="false" data-widget-deletebutton="false">
          <!-- widget options:
          usage: <div class="jarviswidget" id="wid-id-0" data-widget-editbutton="false">
  
          data-widget-colorbutton="false"
          data-widget-editbutton="false"
          data-widget-togglebutton="false"
          data-widget-deletebutton="false"
          data-widget-fullscreenbutton="false"
          data-widget-custombutton="false"
          data-widget-collapsed="true"
          data-widget-sortable="false"
  
          -->
          <header>
            <span class="widget-icon"> <i class="fa fa-table"></i> </span>
            <h2>公共热点日志</h2>
  
          </header>
  
          <!-- widget div-->
          <div>
  
            <!-- widget edit box -->
            <div class="jarviswidget-editbox">
              <!-- This area used as dropdown edit box -->
  
            </div>
            <!-- end widget edit box -->
  
            <!-- widget content -->
            <div class="widget-body no-padding">
              <div class="widget-body-toolbar">
                
              </div>

              <table id="datatable_tabletools" class="table table-striped table-hover vertical-align-middle">
                <thead>
                  <tr>
                    <th>#</th>
                    <th>运营商</th>
                    <th>账号</th>
                    <th>用户手机号</th>
                    <th>状态</th>
                    <th>MAC</th>
                    <th>IP</th>
                    <th>IMEI</th>
                    <th>开始时间</th>
                    <th>结束时间</th>
                  </tr>
                </thead>
                <tbody>
                <% @wifi_logs.each_with_index do |item,index| %>
                  <tr id='item-<%= item.id %>'>
                    <td>
                      <%= index + 1 %>
                    </td>
                    <td><%= { 'liantong' => '联通' }[item.wifi_account.branch] %></td>
                    <td>
                      <%= item.wifi_account.try(:username) %>
                    </td>
                    <td>
                      <%= item.account.try(:mobile_number) %>
                    </td>
                    <td><%= item.end_at ? '使用完毕' : '使用中' %></td>
                    <td>
                      <%= item.mac %>
                    </td>
                    <td>
                      <%= item.ip %>
                    </td>
                    <td>
                      <%= item.imei %>
                    </td>
                    <td><%= item.start_at.strftime('%Y-%m-%d %H:%M:%S') %></td>
                    <td><%= item.end_at.try(:strftime, '%Y-%m-%d %H:%M:%S') %></td>
                  </tr>
                <% end %>
                </tbody>
              </table>
  
            </div>
            <!-- end widget content -->
  
          </div>
          <!-- end widget div -->
  
        </div>
        <!-- end widget -->
  
      </article>
      <!-- WIDGET END -->
  
    </div>
  
    <!-- end row -->
  
  </section>
  <!-- end widget grid -->
<% end %>

<% content_for :js do %>
<% end %>